package com.wyp168.jse.face.question;

/**
 * @ClassName ClassABC
 * @Description TODO
 * @Author wyp168
 * @Date 2022/9/13 23:31
 */
public class ClassC extends classB{
    @Override
    public boolean isPrintClassName() {
        return false;
    }

    public static void main(String[] args) {
        ClassC classC = new ClassC();
        classC.print(classA.class, "hello world");
    }
}


interface classA {
    /**
     * 钩子方法， 表示是否打印类名
     * @return
     */
    boolean isPrintClassName();

    void print(Class clazz, String word);
}

abstract class classB implements classA {
    public abstract boolean isPrintClassName();

    @Override
    public void print(Class clazz, String word) {
        if (isPrintClassName()) {
            System.out.println(clazz.toString());
        }
        System.out.println(word);
    }
}